/*
 * @lc app=leetcode.cn id=55 lang=cpp
 *
 * [55] 跳跃游戏
 */
class Solution
{
public:
    bool canJump(vector<int> &nums)
    {
        int n = nums.size(), reach = 0;
        for (int i = 0; i < n; ++i)
        {
            if (i > reach || reach >= n - 1)
                break;
            reach = max(reach, i + nums[i]);
        }
        return reach >= n - 1;
    }
};
